package com.zelix;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Hashtable;

public class fu extends kt
        implements sm {

    boolean k;
    ks l;
    ks m;
    zs n;
    int o;
    byte[] p;

    fu(kt kt1, jb jb, qy qy1, PrintWriter printwriter)
            throws IOException {
        super(kt1);
        int i;
        int j;
        int i1;
        k = true;
        i = jb.readUnsignedShort();
        j = jb.readUnsignedShort();
        i1 = jb.readUnsignedShort();
        o = jb.readUnsignedShort();
        is is1 = a(i);
        is is2 = a(j);
        is is3 = a(i1);
        if ((is1 instanceof ks) && (j == 0 || (is2 instanceof ks))) {
            l = (ks) is1;
            if (j != 0)
                m = (ks) is2;
            if (i1 != 0) {
                if (is3 instanceof zs) {
                    n = (zs) is3;
                    qy1.b(n, this);
                } else {
                    k = false;
                }
            }
        } else {
            k = false;
        }
        if (!k) {
            p = new byte[8];
            p[0] = (byte) gx.a(i);
            p[1] = (byte) gx.b(i);
            p[2] = (byte) gx.a(j);
            p[3] = (byte) gx.b(j);
            p[4] = (byte) gx.a(i1);
            p[5] = (byte) gx.b(i1);
            p[6] = (byte) gx.a(o);
            p[7] = (byte) gx.b(o);
        }
    }

    public void a(zs zs1, zs zs2) {
        if (n == zs1)
            n = zs2;
    }

    int q() {
        return o;
    }

    String r() {
        String s1;
        String s2;
        if (m != null) {
            s1 = m.b();
            s2 = l.b();
            while ((s2 != null && !s1.startsWith(s2))) {
                int j = s2.lastIndexOf("$");
                int i1 = s2.lastIndexOf("+");
                int i = Math.max(j, i1);
                if (i > 0) {
                    s2 = s2.substring(0, i);
                } else {
                    s2 = null;
                }
            }
            return s2;
        }
        return null;
    }

    public String s() {
        if (m != null) {
            String s1 = m.b();
            if (!s1.equals(""))
                return s1;
        }
        return null;
    }

    public String a() {
        if (l != null) {
            String s1 = l.b();
            if (!s1.equals(""))
                return s1;
        }
        return null;
    }

    String t() {
        if (n != null) {
            String s1 = n.b();
            if (!s1.equals(""))
                return s1;
        }
        return null;
    }

    void b(HashSet hashset) {
        if (l != null)
            hashset.add(l);
        if (m != null)
            hashset.add(m);
    }

    void a(Hashtable hashtable) {
        if (n != null)
            hashtable.put(n, this);
    }

    boolean a(HashSet hashset, Hashtable hashtable) {
        String s1 = l.b();
        mt mt = fh.a(s1);
        if (mt != null) {
            boolean flag = hashset.contains(mt);
            if (flag && n != null)
                hashtable.put(n, n);
            return flag;
        } else {
            return false;
        }
    }

    boolean a(ed ed, Hashtable hashtable) {
        String s1 = l.b();
        mt mt = fh.a(s1);
        if (mt != null) {
            boolean flag = ed.a(mt) ^ true;
            if (flag && n != null)
                hashtable.put(n, n);
            return flag;
        } else {
            return false;
        }
    }

    void u() {
        String s2;
        if (n != null && n.b().length() > 0) {
            String s1 = l.b();
            int i = s1.lastIndexOf('$');
            int j = s1.lastIndexOf('+');
            int i1 = Math.max(i, j);
            if (i1 != -1) {
                s2 = s1.substring(i1 + 1);
            } else
                s2 = "";
            n.a(s2);
        }
    }

    protected void a(DataOutputStream dataoutputstream)
            throws IOException {
        if (k) {
            dataoutputstream.writeShort(l.j());
            dataoutputstream.writeShort(m != null ? m.j() : 0);
            dataoutputstream.writeShort(n != null ? n.j() : 0);
            dataoutputstream.writeShort(o);
        } else
            dataoutputstream.write(p);
    }

    protected void a(DataOutputStream dataoutputstream, Hashtable hashtable)
            throws IOException {
        if (k) {
            dataoutputstream.writeShort(l.j());
            dataoutputstream.writeShort(m != null ? m.j() : 0);
            if (n == null) {
                dataoutputstream.writeShort(0);
            } else {
                zs zs1 = (zs) hashtable.get(n);
                if (zs1 != null) {
                    dataoutputstream.writeShort(zs1.j());
                } else {
                    dataoutputstream.writeShort(n.j());
                }
            }
            dataoutputstream.writeShort(o);
        } else {
            dataoutputstream.write(p);
        }
    }
}